package edu.zjut.hjg.saas.kwmp.web.theme;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ThemeResolver;

import edu.zjut.hjg.saas.biz.model.Kindergarten;
import edu.zjut.hjg.saas.kwmp.web.support.KwmpConstants;

public class AppThemeResolver implements ThemeResolver {
    private final static String DEFAULT_THEME_NAME = "theme1";

    @Override
    public String resolveThemeName(HttpServletRequest request) {
        Kindergarten app = (Kindergarten) request.getAttribute(KwmpConstants.RQUEST_ATTRIBUTE_APP);
        if (app == null) {
            return DEFAULT_THEME_NAME;
        }
        return app.getMeta().getTheme();
    }

    @Override
    public void setThemeName(HttpServletRequest request, HttpServletResponse response,
                             String themeName) {
    }
}
